# $Id: PKGBUILD 143745 2011-11-28 20:14:39Z giovanni $
# Maintainer: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: dale <dale@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgname=gpart
pkgver=0.1h
pkgrel=5
pkgdesc="Partition table rescue/guessing tool"
arch=('i686' 'x86_64')
url="http://www.stud.uni-hannover.de/user/76201/gpart/"
license=('GPL')
depends=('glibc')
source=("http://www.sfr-fresh.com/linux/misc/${pkgname}-${pkgver}.tar.gz"
        'gpart-0.1h-errno.patch' 
        'gpart-0.1h-vfat.patch' 
        'gpart-0.1h-ntfs.patch'
        'gpart-0.1h-reiserfs-3.6.patch'
        'gpart-0.1h-l64seek.patch'
        'gpart-0.1h-openmode.patch')
md5sums=('ee3a2d2dde70bcf404eb354b3d1ee6d4'
         '81eee5d9985df9bf9c23624e46cf945f'
         'ae6d86b0268618d34e618824dcd82754'
         '8161c02116ee4575906587eb09e35bde'
         '5da425c355740cbf06286755c902b996'
         '9cd7f91c321a83cc1aa202744d1c7cd2'
         'c982a01385e99b86b32de536c1fbecfb')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  patch -Np1 -i ${srcdir}/gpart-0.1h-errno.patch
  patch -Np1 -i ${srcdir}/gpart-0.1h-vfat.patch
  patch -Np1 -i ${srcdir}/gpart-0.1h-ntfs.patch
  patch -Np2 -i ${srcdir}/gpart-0.1h-reiserfs-3.6.patch
  patch -Np1 -i ${srcdir}/gpart-0.1h-l64seek.patch
  patch -Np1 -i ${srcdir}/gpart-0.1h-openmode.patch

  sed -i -e "/^CFLAGS/s: -O2 : ${CFLAGS} :" make.defs
  sed -i -e "/^LDFLAGS/s:=:=${LDFLAGS} :" make.defs

  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make prefix=${pkgdir}/usr mandir=${pkgdir}/usr/share/man install
}
